package net.kmd.controller;

import lombok.extern.slf4j.Slf4j;
import net.kmd.service.impl.KafkaServiceImpl;
import net.kmd.utiles.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("api/v1/Kafka")
public class KafkaController {


    private final KafkaProducer kafkaProducer;
    private final KafkaServiceImpl kafkaService;

    @Autowired
    public KafkaController(KafkaProducer kafkaProducer, KafkaServiceImpl kafkaService) {
        this.kafkaProducer = kafkaProducer;
        this.kafkaService = kafkaService;
    }

    @RequestMapping("createProducer")
    @ResponseBody
    public Object createProducer() {
        Object value = kafkaService.createProducer();
        kafkaProducer.send(value);
        log.info("createProducer");
        return "1";
    }

    ;

}
